home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / dpkg.preinst < prev    next >
Text File  |  2009-09-20  |  2KB  |  87 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17. # Handle upgrades from pre-conffile dpkg.cfg
  18. upgrade_dpkg_non_conffile()
  19. {
  20.     if [ -r /etc/dpkg/dpkg.cfg ]; then
  21.     dpkg_cfg_md5="535552ad5ee9145dbc7a34c264df4e59  /etc/dpkg/dpkg.cfg"
  22.     if echo "$dpkg_cfg_md5" | md5sum -c >/dev/null 2>&1; then
  23.         echo "Removing non-modified dpkg.cfg to be replaced by a conffile ..."
  24.         rm -f /etc/dpkg/dpkg.cfg
  25.     fi
  26.     fi
  27. }
  28.  
  29. kill_bad_alternatives () {
  30.     local IFS=""
  31.     ALTDIR="/var/lib/dpkg/alternatives"
  32.     for alt in $ALTDIR/*; do
  33.         if [ ! -f $alt ]; then
  34.             # In case it's been removed by the code below, or in case
  35.             # it's not a real file
  36.             continue
  37.         fi
  38.         {
  39.             read mode || continue
  40.             read mainlink || continue
  41.             while true; do
  42.                 read slave || break
  43.                 if [ "$slave" = "" ]; then
  44.                     break
  45.                 fi
  46.                 if [ -e "$ALTDIR/$slave" ]; then
  47.                     echo "Removing conflicting master alternative $slave (it is slave of $(basename $alt))..."
  48.                     rm -f "$ALTDIR/$slave"
  49.                 fi
  50.                 read slavelink || break
  51.             done
  52.         } <$alt
  53.     done
  54. }
  55.  
  56. case "$1" in
  57.     install)
  58.     ;;
  59.  
  60.     upgrade)
  61.         # Cleanup bad alternatives that would choke with new
  62.         # update-alternatives (see #530633, #531611, #532739, #521760)
  63.         if dpkg --compare-versions "$2" lt 1.15.3; then
  64.             kill_bad_alternatives
  65.         fi
  66.  
  67.     case "$2" in
  68.         # Upgrade from pre-conffile dpkg.cfg
  69.         1.9.21 | 1.10.* )
  70.         upgrade_dpkg_non_conffile
  71.         ;;
  72.     esac
  73.     ;;
  74.  
  75.     abort-upgrade)
  76.     ;;
  77.  
  78.  
  79.     *)
  80.     echo "$0 called with unknown argument \`$1'" 1>&2
  81.     exit 1
  82.     ;;
  83. esac
  84.  
  85.  
  86. exit 0
  87.